<xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:fn="http://www.w3.org/2005/xpath-functions/" 
  xmlns:wh="whatever">
  <xsl:output omit-xml-declaration="yes"/>
  <xsl:param name="filter1"/>
  <xsl:param name="filter2"/>
 
  <!-- //Rule[TransTypeScope[@tc='1201'] and TransSubTypeScope[@tc='1022500101']]-->

  <xsl:namespace-alias result-prefix="xsl"
                       stylesheet-prefix="wh"/>


  <xsl:template match="/">
    <xsl:variable name="today">
      <xsl:value-of select="format-date(current-date(),'[Y][M12][D12]')"/>
    </xsl:variable>
    <wh:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <wh:output omit-xml-declaration="yes"/>
      <wh:template match="/">
       
        <RulesetResponse>
          <RulesetResponseInfo>            
            <TotalRuleSetRules><xsl:value-of select="count(//Rule)"/></TotalRuleSetRules>
          </RulesetResponseInfo>
          <xsl:for-each select="//Rule">
            <!--Select this Rule if it is Global or if it is in scope for the message to eval -->
            <xsl:if test="empty(./TransTypeScope[@tc]) or
            (./TransTypeScope[@tc=$filter1] and ./TransSubTypeScope[@tc=$filter2]) or 
            (./TransTypeScope[@tc=$filter1] and empty(./TransSubTypeScope))">
              <!--Select this Rule if today is within its date scope, if any -->
              <xsl:if test="(count(./StartDate) = 0 or $today &gt; format-date(./StartDate,'[Y][M12][D12]')) and 
                              (count(./StopDate) = 0 or $today &lt; format-date(./StopDate,'[Y][M12][D12]'))">
                <RuleEvent>
                  <xsl:attribute name="id">
                    <xsl:value-of select="position()"/>
                  </xsl:attribute>
                  <TransResult>
                    <wh:choose>
                      <wh:when>
                        <xsl:attribute name="test">
                          <xsl:value-of select="./RuleValue"/>
                        </xsl:attribute>
                        <ResultCode tc="1">Success</ResultCode>
                      </wh:when>
                      <wh:otherwise>
                        <ResultCode tc="5">Failure</ResultCode>                       
                      </wh:otherwise>
                    </wh:choose>
                    <ResultInfo>
                      <ResultInfoCode tc="1022500000">
                        <xsl:value-of select="./Description"/>
                      </ResultInfoCode>
                      <ResultInfoDesc>
                        <xsl:value-of select="./Message"/>
                      </ResultInfoDesc>
                      <ResultInfoSysMessageCode>
                        <xsl:value-of select="./@id"/>
                      </ResultInfoSysMessageCode>
                      <ResultInfoSeverity>
                        <xsl:attribute name="tc">
                          <xsl:value-of select="./Severity/@tc"/>
                        </xsl:attribute>
                        <xsl:value-of select="./Severity"/>
                      </ResultInfoSeverity>
                      <ResultInfoSource>
                        <xsl:value-of select="./RuleValue"/>
                      </ResultInfoSource>
                    </ResultInfo>
                  </TransResult>
                </RuleEvent>
              </xsl:if>
            </xsl:if>
          </xsl:for-each>
        </RulesetResponse>
           
              
      </wh:template>
    </wh:stylesheet>

  </xsl:template>



</xsl:stylesheet>

